﻿using Microsoft.VisualStudio.DebuggerVisualizers;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.ComponentModel;

[assembly: DebuggerVisualizer(  typeof(DependencyObjectTreeViewer.DependencyObjectVisualizer),
                                typeof(DependencyObjectTreeViewer.DependencyObjectObjectSource),
                                Target = typeof(DependencyObject),
                                Description = "DependencyObject Treeview")]

namespace DependencyObjectTreeViewer
{
    public class DependencyObjectVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            BinaryFormatter formatter = new BinaryFormatter();
            DependencyObjectData data = (DependencyObjectData)formatter.Deserialize(objectProvider.GetData());

            using (DependencyObjectTreeForm displayForm = new DependencyObjectTreeForm(data))
            {
                windowService.ShowDialog(displayForm);
            }
        }
    }
}